#include "list.h"
#include<iostream>

//头部添加
void List::head_add(TYPE data)
{
    if(head==NULL)
    {
        head->data=data;
        head->next=NULL;
    }
    else
    {
        Node* node=new Node;
        node=head;
        head->data=data;
        head->next=node;
        delete node;
    }
}
bool List::head_del()
{
    if (head==NULL)
    {
        return false;
    }
    else
    {
        head=head->next;
        return true;
    }
}
void List::tail_add(TYPE data)
{
    if(NULL==head)
    {
        head->data=data;
        head->next=NULL;
        std::cout<< head->data>>std::endl;
    }
    else
    {
        Node* node =head;
        while(NULL!=node->next)
        {
            node=node->next;
        }
        Node* pth =new Node(data);
        node->next=pth;
        head=node;
        delete pth;

    }
    
}
bool List::tail_del()
{
    if(NULL==head)
    {
        return false;
    }
    if (NULL==head->next)
    {
        return head_del();
    }
    Node* node=head;
    while(NULL!=node->next)
    {
        node=node->next;
    }
    node->next=NULL;
    head=node;
    return true;
}
void List::show_list()
{
    Node* node
    node=head;
    while(NULL!=head)
    {
        cout<<head->data<<endl;
        head=head->next;
    }
    head=node;
}
size_t List::size()
{
    Node* node=head;
    int size=0;
    while(NULL!=node)
    {
        size++;
        node=node->next;
    }
    return size;
}